<!doctype html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
  <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  <title>消费明细</title>
  <link rel="stylesheet" type="text/css" href="../css/api.css" />
  <link rel="stylesheet" type="text/css" href="../css/income.css" />
</head>

<body>
  <div id="app" v-cloak>
    <div class="wrap flex-wrap flex-vertical">
      <header id="header">
        <div class="header-wrap border-bottom">
          <div @click="goback" class="header-left">
            <i class="iconfont icon-pre"></i>
          </div>
          <div class="header-title">消费明细</div>
        </div>
      </header>
      <div class="flex-con">
        <div class="income-list">
          <div v-if="incomeList.length == 0" class="empty-wrap">
            <img class="empty-img" src="../image/empty.png">
            <div class="empty-text">暂无消费</div>
          </div>
          <div v-else class="income-item" v-for="(item, i) in incomeList" :key="item.id">
            <div class="income-item-info">
              <div class="info">{{item.description}}</div>
              <div class="time">{{item.updated_at}}</div>
            </div>
            <div class="income-item-money">
              <span>消费：</span>
              <i class="icon icon-gold"></i>
              <!-- <img class="zuan-icon" src="../image/zuan1_icon.png" alt=""> -->
              <span>{{item.gold}}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</body>

</html>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/vue.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript">
  var app;
  apiready = function () {
    $api.fixStatusBar($api.dom('#header'));
    api.setStatusBarStyle({
      style: 'light',
    });
    app = new Vue({
      el: '#app',
      data: {
        type: '',
        incomeList: []
      },
      created: function () {},
      mounted: function () {
        this.getUserIncome('outlaie');
      },
      methods: {
        getUserIncome: function (type) {
          var _this = this;
          api.showProgress({
            title: '',
            text: '加载中...'
          });
          api.ajax({
            url: baseUrl + 'user/income',
            method: 'get',
            headers: {
              token: $api.getStorage('deviceToken')
            },
            data: {
              values: {
                uid: $api.getStorage('uid'),
                type: type
              },
            }
          }, function (ret, err) {
            api.hideProgress();
            if (ret.status == 200) {
              _this.incomeList = ret.data.list;
            }
          })
        },

        goback: function () {
          api.closeWin();
        },
      },
    })
  }
</script>